<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="开机">
    <meta name="keyword" content="登录, 作者, 信息">

    <title>作者登录</title>
	<#include "admin/common.ftl" />
</head>

  <body class="login-body">

    <div class="container">

      <form id="listForm" class="form-signin" action="${ctx}/admin/author/login.html" method="post">
        <h2 class="form-signin-heading">开机博客登录</h2>
        <div class="login-wrap">
            <input type="text" class="form-control" name="phone" placeholder="手机号码" autofocus autocomplete="off">
            <input type="password" class="form-control" name="password" placeholder="密码" autocomplete="off">
            <label class="checkbox">
                <input type="checkbox" value="remember-me"> 记住我
                <span class="pull-right"> <a href="#"> 忘记密码?</a></span>
            </label>
            <button class="btn btn-lg btn-login btn-block" type="submit">登录</button>
            <p>或者你也可以使用下面的方式登录</p>
            <div class="login-social-link">
                <a href="index.html" class="facebook">
                    <i class="icon-facebook"></i>
                    Facebook
                </a>
                <a href="index.html" class="twitter">
                    <i class="icon-twitter"></i>
                    Twitter
                </a>
            </div>
        </div>
      </form>
    </div>
    
    
    <#include "admin/common_js.ftl" />
    <script src="${ctx}/js/jquery.validate.min.js" ></script>
      <script type="text/javascript">
    	$("#listForm").validate({
    		rules: {
    			"phone" : {
    				required: true,
    				digits: true,
        			minlength: 11,
        			maxlength: 11
    			},
    			"password" : {
    				required: true,
        			minlength: 4,
        			maxlength: 12
    			}
    		},
    		messages: {
    			"phone" : {
    				required: true,
    				digits: "只能输入整数",
        			minlength: "只能是11位数!",
        			maxlength: "只能是11位数!"
    			},
    			"password" : {
    				required: "请输入密码!",
        			minlength: "最少4位",
        			maxlength: "最大12位"
    			}
    		},
			submitHandler: function(form) {   
				$.ajax({
					url: $(form).attr("action"),
					data: $("#listForm").serialize(),
		            type: "post",
		            dataType: "json",
		            success: function(data) {
		            	if (data.success == 0) {
							layer.alert(data.message, {icon: 5});
		            	} else {
		            		location.href="${ctx}/admin/home/index.html";
		            	}
		            }
				});
		   	}  
		 });
    </script>

    </body>
</html>
